﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MTViewer
{
    /// <summary>
    /// Interaction logic for ctrlCapMatrix.xaml
    /// </summary>
    public partial class ctrlCapMatrix : UserControl, ITouchObject
    {
        public ctrlCapMatrix()
        {
            InitializeComponent();
            DataContext = this;

            btn1.OnClick += new EventHandler(PanelButton_OnClick);
            btn2.OnClick += new EventHandler(PanelButton_OnClick);
            btn3.OnClick += new EventHandler(PanelButton_OnClick);
            btn4.OnClick += new EventHandler(PanelButton_OnClick);
            btn5.OnClick += new EventHandler(PanelButton_OnClick);
            btn6.OnClick += new EventHandler(PanelButton_OnClick);
            btn7.OnClick += new EventHandler(PanelButton_OnClick);
            btn8.OnClick += new EventHandler(PanelButton_OnClick);
            btn9.OnClick += new EventHandler(PanelButton_OnClick);
            btn10.OnClick += new EventHandler(PanelButton_OnClick);
            btn11.OnClick += new EventHandler(PanelButton_OnClick);
            btn12.OnClick += new EventHandler(PanelButton_OnClick);
            btn13.OnClick += new EventHandler(PanelButton_OnClick);
            btn14.OnClick += new EventHandler(PanelButton_OnClick);
            btn15.OnClick += new EventHandler(PanelButton_OnClick);
            btn16.OnClick += new EventHandler(PanelButton_OnClick);
            btn17.OnClick += new EventHandler(PanelButton_OnClick);
            btn18.OnClick += new EventHandler(PanelButton_OnClick);
            btn19.OnClick += new EventHandler(PanelButton_OnClick);
            btn20.OnClick += new EventHandler(PanelButton_OnClick);
            btn21.OnClick += new EventHandler(PanelButton_OnClick);
            btn22.OnClick += new EventHandler(PanelButton_OnClick);
            btn23.OnClick += new EventHandler(PanelButton_OnClick);
            btn24.OnClick += new EventHandler(PanelButton_OnClick);
            btn25.OnClick += new EventHandler(PanelButton_OnClick);
            btn26.OnClick += new EventHandler(PanelButton_OnClick);
            btn27.OnClick += new EventHandler(PanelButton_OnClick);
            btn28.OnClick += new EventHandler(PanelButton_OnClick);
            btn29.OnClick += new EventHandler(PanelButton_OnClick);
            btn30.OnClick += new EventHandler(PanelButton_OnClick);
            btn31.OnClick += new EventHandler(PanelButton_OnClick);
            btn32.OnClick += new EventHandler(PanelButton_OnClick);
            btn33.OnClick += new EventHandler(PanelButton_OnClick);
            btn34.OnClick += new EventHandler(PanelButton_OnClick);
            btn35.OnClick += new EventHandler(PanelButton_OnClick);
            btn36.OnClick += new EventHandler(PanelButton_OnClick);
            btn37.OnClick += new EventHandler(PanelButton_OnClick);
            btn39.OnClick += new EventHandler(PanelButton_OnClick);
            btn40.OnClick += new EventHandler(PanelButton_OnClick);

            btn1.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn2.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn3.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn4.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn5.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn6.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn7.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn8.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn9.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn10.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn11.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn12.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn13.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn14.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn15.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn16.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn17.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn18.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn19.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn20.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn21.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn22.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn23.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn24.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn25.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn26.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn27.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn28.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn29.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn30.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn31.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn32.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn33.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn34.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn35.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn36.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn37.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn39.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
            btn40.TouchDown += new EventHandler<TouchEventArgs>(PanelButton_TouchDown);
        }

        void PanelButton_TouchDown(object sender, TouchEventArgs e)
        {
            PanelButton_OnClick(sender, e);
        }

        void PanelButton_OnClick(object sender, EventArgs e)
        {
            string causeName = PanelButton.GetCauseName((UIElement)sender);

            if (OnCreateControl != null)
            { 
                PIBV.LoadDrawingEventArgs arg = new PIBV.LoadDrawingEventArgs(new Point(300,300),causeName + ".cef","","","","");
                OnCreateControl(this, arg);
            }
        }

        public string ImagePath
        {
            get { return (string)GetValue(ImagePathProperty); }
            set { SetValue(ImagePathProperty, value); }
        }

        public double Angle
        {
            get { return (double)GetValue(AngleProperty); }
            set { SetValue(AngleProperty, value); }
        }

        public double ScaleX
        {
            get { return (double)GetValue(ScaleXProperty); }
            set { SetValue(ScaleXProperty, value); }
        }

        public double ScaleY
        {
            get { return (double)GetValue(ScaleYProperty); }
            set { SetValue(ScaleYProperty, value); }
        }

        public double X
        {
            get { return (double)GetValue(XProperty); }
            set { SetValue(XProperty, value); }
        }

        public double Y
        {
            get { return (double)GetValue(YProperty); }
            set { SetValue(YProperty, value); }
        }

        public string PdfFileName
        {
            get { return (string)GetValue(PdfFileNameProperty); }
            set { SetValue(PdfFileNameProperty, value); }
        }

        public string DgnFileName
        {
            get { return (string)GetValue(DgnFileNameProperty); }
            set { SetValue(DgnFileNameProperty, value); }
        }

        public string OriginalImagePath
        {
            get { return (string)GetValue(OriginalImagePathProperty); }
            set { SetValue(OriginalImagePathProperty, value); }
        }

        #region DependencyProperties

        // Using a DependencyProperty as the backing store for ImagePath.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ImagePathProperty =
            DependencyProperty.Register("ImagePath", typeof(string), typeof(ctrlCapMatrix), new UIPropertyMetadata(""));

        // Using a DependencyProperty as the backing store for Angle.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty AngleProperty =
            DependencyProperty.Register("Angle", typeof(double), typeof(ctrlCapMatrix), new UIPropertyMetadata(0.0));

        // Using a DependencyProperty as the backing store for ScaleX.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ScaleXProperty =
            DependencyProperty.Register("ScaleX", typeof(double), typeof(ctrlCapMatrix), new UIPropertyMetadata(1.0));

        // Using a DependencyProperty as the backing store for ScaleY.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ScaleYProperty =
            DependencyProperty.Register("ScaleY", typeof(double), typeof(ctrlCapMatrix), new UIPropertyMetadata(1.0));

        // Using a DependencyProperty as the backing store for X.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty XProperty =
            DependencyProperty.Register("X", typeof(double), typeof(ctrlCapMatrix), new UIPropertyMetadata(0.0));

        // Using a DependencyProperty as the backing store for Y.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty YProperty =
            DependencyProperty.Register("Y", typeof(double), typeof(ctrlCapMatrix), new UIPropertyMetadata(0.0));

        // Using a DependencyProperty as the backing store for ImagePath.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty PdfFileNameProperty =
            DependencyProperty.Register("PdfFileName", typeof(string), typeof(ctrlCapMatrix), new UIPropertyMetadata(""));

        // Using a DependencyProperty as the backing store for ImagePath.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty OriginalImagePathProperty =
            DependencyProperty.Register("OriginalImagePath", typeof(string), typeof(ctrlCapMatrix), new UIPropertyMetadata(""));
        
        // Using a DependencyProperty as the backing store for ImagePath.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty DgnFileNameProperty =
            DependencyProperty.Register("DgnFileName", typeof(string), typeof(ctrlCapMatrix), new UIPropertyMetadata(""));
        
                
        #endregion

        public event EventHandler<PIBV.LoadDrawingEventArgs> OnCreateControl;

    }
}
